# schemas/message.py
from pydantic import BaseModel, ConfigDict
from datetime import datetime
from typing import Optional, List


class MessageCreate(BaseModel):
    title: str
    content: str
    type: Optional[str] = "info"


class MessageOut(BaseModel):
    id: int
    title: str
    content: str
    type: str
    status: str
    created_at: datetime

    model_config = {
        "from_attributes": True
    }


class MessageOutWrapper(BaseModel):
    code: int
    message: str
    data: List[MessageOut]
    model_config = ConfigDict(from_attributes=True)  # 允许从 ORM 对象创建
